home *** CD-ROM | disk | FTP | other *** search
/ Gekkan Dennou Club 145 / Gekkan Dennou Club - 2000.6 Vol. 145 (Japan).7z / Gekkan Dennou Club - 2000.6 Vol. 145 (Japan) (Track 1).bin / games / spassion / source.lzh / SOURCE / FuncEnemy / BRAIN.C < prev    next >
Text File  |  2000-03-24  |  3KB  |  140 lines

  1. /*
  2. #include <stdio.h>
  3. #include <iocslib.h>
  4. void    key_wait( void );
  5. #define BIT(i)        (1<<(i))
  6. */
  7. /*
  8. 脳っぽいやつ
  9. */
  10. #include <xsp2lib.h>
  11. #include "../SPASSION.H"
  12. #include "../player.h"
  13. #include "../enemy.h"
  14. #include "../eshot.h"
  15. #include "../effect.h"
  16. #include "../priority.h"
  17. #include "../sound.h"
  18. #include "../entry.h"
  19. #ifndef NULL
  20. #define NULL ((void *) 0)
  21. #endif
  22.  
  23. #define PALET_MAIN    0x0A00
  24.  
  25. static short MoveEnemyBrain( ENEMY *ene );
  26. /*static void TiniEnemyBrain(ENEMY *);*/
  27. static short MoveEnemyBrain(ENEMY *);
  28. /*static void TiniEnemyBrain(ENEMY *);*/
  29.  
  30. static HIT_XY4    hit_p[8];
  31. static HIT_XY4    hit_o[8];
  32. static HIT_XY4    hit_s[8]={
  33.     -12,-12,12,12,
  34.     -12,-12,12,12,
  35.     -12,-12,12,12,
  36.     -12,-12,12,12,
  37.     -11,-11,11,11,
  38.     -10,-10,10,10,
  39.      -9, -9, 9, 9,
  40.      -8, -8, 8, 8,
  41. };
  42.  
  43. static unsigned char seed=0;
  44.  
  45. void InitEnemyBrainHit( void )
  46. {
  47.     short    i;
  48.     for(i=0;i<8;i++){
  49.         hit_p[i].x1=hit_s[i].x1-PLAYER_HIT_X;hit_p[i].y1=hit_s[i].y1-PLAYER_HIT_Y;
  50.         hit_p[i].x2=hit_s[i].x2+PLAYER_HIT_X;hit_p[i].y2=hit_s[i].y2+PLAYER_HIT_Y;
  51.         hit_o[i].x1=hit_s[i].x1-OPTION_HIT_X;hit_o[i].y1=hit_s[i].y1-OPTION_HIT_Y;
  52.         hit_o[i].x2=hit_s[i].x2+OPTION_HIT_X;hit_o[i].y2=hit_s[i].y2+OPTION_HIT_Y;
  53.     }
  54. }
  55.  
  56. void InitEnemyBrain(ENEMY *ene)
  57. {
  58.     ene->info         = PALET_MAIN | PRIORITY_ZAKO;
  59.     ene->vx             = (ene->arg>>8          ) * 32768;        /* 引数の上位バイトをvxにする */
  60.     ene->vy             = ((char)(ene->arg&0xFF)) * 32768;        /* 引数の下位バイトをvyにする */
  61.  
  62.     ene->hit_p[0]     = &hit_p[0];ene->hit_p[1]=NULL;
  63.     ene->hit_o[0]     = &hit_o[0];ene->hit_o[1]=NULL;
  64.     ene->hit_s[0]     = &hit_s[0];ene->hit_s[1]=NULL;
  65.     ene->hp = 20;
  66.     if( rndtable[seed++]>127 )
  67.         ene->arg=0;
  68.     else
  69.         ene->arg=9;
  70.     seed&=255;
  71.     ene->no_dead     = 0;
  72.     ene->func_enemy_move = MoveEnemyBrain;
  73. /*    ene->func_enemy_tini = TiniEnemyBrain;*/
  74.  
  75. /*    entry_counter_stop = !0;*/        /* エントリーカウンター停止 */
  76. }
  77.  
  78. static short MoveEnemyBrain( ENEMY *ene )
  79. {
  80.     short    anim_num,anim_pt;
  81.     short    pt[]={11,11,11,11,12,13,14,15,-1,16,16,16,16,17,18,19,20,-1};
  82.  
  83.     /* 速度を足して上位ワード(固定整数部)だけ取り出す */
  84.     ene->x = ((ene->lx += ene->vx) >> 16);
  85.     ene->y = ((ene->ly += ene->vy) >> 16);
  86.  
  87.     ene->pt = obj_obj_b+(anim_pt=pt[ene->arg+(anim_num=(++ene->anim_count)/4)]);
  88.     if( anim_pt == -1 ){
  89.         ene->pt = obj_obj_b+pt[ene->arg];
  90.         ene->anim_count=0;
  91.         anim_num=0;
  92.     }
  93.     ene->hit_p[0] = &hit_p[anim_num];
  94.     ene->hit_o[0] = &hit_o[anim_num];
  95.     ene->hit_s[0] = &hit_s[anim_num];
  96. #if 0
  97.     if(ENE_X < 128){
  98.         ene->lx = 128*65536;
  99.         ene->ly = 128*65536;
  100.         ene->vx = 0;
  101.         ene->vy = 0;
  102.     }
  103.     if( BITSNS(0x04) & BIT(1) ){        /* F */
  104.         while( BITSNS(0x04) & BIT(1) );
  105.         entry_counter_stop = 0;
  106.         return (0);
  107.     }
  108. #endif
  109.  
  110.     /* 画面外に出たら消去 */
  111.     if( ENE_X < 0 - 32 )
  112.         return (0);
  113.  
  114.     /* ダメージを受けた時の処理 */
  115. #if 1
  116.     if(ene->damage){
  117.         SetSE(SE_DAMAGE);    /* 効果音 */
  118.         ene->info = PALET_DAMAGE | PRIORITY_BOSS;    /*パレット変更*/
  119.         if((ene->hp -= ene->damage) <= 0) {
  120.             MakeEffect(EFFECT_EXPL, 0, ene->x, ene->y);
  121.             SetSE(SE_EXPL_BRAIN);    /* 爆発音 */
  122.             ene->player->score += 3;
  123.             return (0);        /* 消去 */
  124.         }
  125.         ene->damage = 0;
  126.     }else
  127.         ene->info = PALET_MAIN | PRIORITY_ZAKO;
  128. #endif
  129.     xobj_set_st(ene);
  130.  
  131.     return(1);
  132. }
  133.  
  134.  
  135. /*
  136. static void TiniEnemyBrain(ENEMY * p)
  137. {
  138. }
  139. */
  140.